package com.globallogic.jira.generators;

import java.util.Collection;
import java.util.HashMap;
import java.util.Map;

import com.atlassian.configurable.ValuesGenerator;
import com.atlassian.jira.ComponentManager;
import com.atlassian.jira.issue.link.IssueLinkType;
import com.atlassian.jira.issue.link.IssueLinkTypeManager;

/**
 * @author A.Pereverziev
 */
public class LinkValuesGenerator implements ValuesGenerator {
    public Map<String, String> getValues(
	    @SuppressWarnings("rawtypes") Map userParams) {
	Map<String, String> linksMap = new HashMap<String, String>();

	ComponentManager.getInstance();
	IssueLinkTypeManager issueLinkTypeManager = ComponentManager
		.getComponentInstanceOfType(IssueLinkTypeManager.class);

	Collection<IssueLinkType> linkTypes = issueLinkTypeManager
		.getIssueLinkTypes();

	linksMap.put("All", "All");
	for (IssueLinkType linkType : linkTypes) {
	    linksMap.put(linkType.getName().replace(" ", "+"),
		    linkType.getName());
	}

	return linksMap;
    }
}